'\" te
.\" Copyright (c) David L. Mills 1992, 1993, 1994, 1995, 1996, 1997
.\" Portions Copyright (c) 1997, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH NTP_GETTIME 2 "May 13, 2017"
.SH NAME
ntp_gettime \- get local clock values
.SH SYNOPSIS
.LP
.nf
#include <sys/timex.h>

\fBint\fR \fBntp_gettime\fR(\fBstruct ntptimeval *\fR\fItptr\fR);
.fi

.SH DESCRIPTION
.LP
The \fBntp_gettime()\fR function reads the local clock value and dispersion,
returning the information in \fItptr\fR.
.sp
.LP
The \fBntptimeval\fR structure contains the following members:
.sp
.in +2
.nf
struct ntptimeval {
    struct timeval   time;       /* current time (ro) */
    int32_t          maxerror;   /* maximum error (us) (ro) */
    int32_t          esterror;   /* estimated error (us) (ro) */
};
.fi
.in -2

.SH RETURN VALUES
.LP
Upon successful completion, \fBntp_gettime()\fR returns the current clock state
(see <\fBsys/timex.h\fR>). Otherwise, it returns \fB\(mi1\fR and sets
\fBerrno\fR to indicate the error.
.SH ERRORS
.LP
The \fBntp_gettime()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBEFAULT\fR\fR
.ad
.RS 10n
The \fItptr\fR argument points to an invalid address.
.RE

.sp
.LP
The \fBntp_gettime()\fR function will fail for 32-bit interfaces if:
.sp
.ne 2
.na
\fB\fBEOVERFLOW\fR\fR
.ad
.RS 13n
The size of the \fBtime.tv_sec\fR member of the \fBntptimeval\fR structure
pointed to by \fItptr\fR is too small to contain the correct number of seconds.
.RE

.SH SEE ALSO
.LP
.BR ntp_adjtime (2)
